package com.class06;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/servletA")
public class ServletA extends HttpServlet{
    @Override
    protected void service(HttpServletRequest req,
                           HttpServletResponse resp) throws
            ServletException, IOException {
//        1、创建Cookie对象
        Cookie cookie = new Cookie("name", "zhangsan");
//        设置cookie的路径
        cookie.setPath("/servletB");
        Cookie cookie1 = new Cookie("password", "124567");
//        2、设置cookie的存活时间60分钟
        cookie.setMaxAge(60*60);
        resp.addCookie(cookie);
        resp.addCookie(cookie1);
        resp.getWriter().println("ok");


    }
}
